package radio;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.Window.Type;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;

public class streamDoCliente extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final JPanel contentPanel = new JPanel();
	private JTextField textClienteIndicado;
	private JTable tableStreamCliente;

	/* vai carregar a tableStreamCliente apontada pela radio e cliente */
	public streamDoCliente(Radio novaRadio, Cliente cliente) {
		setModal(true);
		setResizable(false);
		setType(Type.UTILITY);
		setBounds(100, 100, 628, 386);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 36, 592, 267);
		contentPanel.add(scrollPane);
		
		tableStreamCliente = new JTable();
		tableStreamCliente.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"New column", "New column", "New column"
			}
		));
		scrollPane.setViewportView(tableStreamCliente);
		
		JLabel lblListaDeMusicas = new JLabel("Lista de Musicas Indicadas para o Cliente:");
		lblListaDeMusicas.setBounds(10, 11, 277, 14);
		contentPanel.add(lblListaDeMusicas);
		
		textClienteIndicado = new JTextField();
		textClienteIndicado.setEnabled(false);
		textClienteIndicado.setEditable(false);
		textClienteIndicado.setBounds(325, 5, 277, 20);
		contentPanel.add(textClienteIndicado);
		textClienteIndicado.setColumns(10);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton cancelButton = new JButton("Fechar");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
					
					}
				});
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
		
		/*** Carrega a lista de musicas indicadas para o cliente **/
		
		ArrayList<Musica> listaDeMusicas = new ArrayList<>();
        listaDeMusicas.addAll(novaRadio.recomedarMusicasParaClienteNovo(cliente));
        TabelaModeloStreamCliente modelo3 = new TabelaModeloStreamCliente(listaDeMusicas);
        tableStreamCliente.setModel(modelo3);
        textClienteIndicado.setText(cliente.getNome());
		
		
	}
}
